package com.t2two.example.common.dataresult;


/**
 * @author 李飞
 */
public enum ResultCode {

    /**
     * 错误码
     */
    SUCCESS(200, "成功"),
    SYSTEM_ERROR(-99, "系统错误"),
    DB_ERROR(-98, "数据库错误"),
    DATA_NOT_FOUND(-1, "数据不存在，[%s]"),
    ILLEGAL_PARAMETER(-2, "参数不合法，[%s]"),
    DUPLICATE_INSERT(-3, "唯一索引冲突，[%s]"),
    REQUIRED_PARAMETER(-4, "参数不允许为空：[%s]"),
    DUPLICATE_REQUEST(102, "duplicate request"),
    STATES_ERROR(103, "状态不合法"),
    DUPLICATE_DATA(104, "duplicate data"),

    UNKNOWN_ERROR(0, "未知错误"),
    SYSTEM_EXCEPTION(1, "系统异常"),

    V_COMMON_PARAM_ERROR(-100, "参数错误，[%s]"),

    MODEL_NULL(100000, "模型为空"),
    MODEL_STATUS_MISMATCH(100001, "模型状态不匹配"),;

    private String message;

    private int code;

    ResultCode(int code, String message) {
        this.setCode(code);
        this.setMessage(message);
    }

    public String getMessage() {
        return message;
    }

    public String getMessage(Object... args) {
        return String.format(getMessage(), args);
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

}

